﻿<%@ Page Title="Avail. Open Fares" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AvailOpenFares.aspx.cs" Inherits="IFD2.AvailOpenFares" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <script>
    <!-- Hide
    /* var popY;
    var popupHeight=350;//120
    var titlePopup;
    var len;
   
       function InitMsgBox(content)
       {
        //if(navigator.appName=="Microsoft Internet Explorer")
        //{
        //    //createPopup() is just compatible with IE
        //    len = 0;
        //    titlePopup=window.createPopup();
        //    var titlePopupBody = titlePopup.document.body;
        //    titlePopupBody.style.border ="solid #999999 1px";
        //    titlePopupBody.style.backgroundColor = "#f9f8f7"; 
        //    titlePopupBody.style.fontSize = "12px"; 
        //    var titleContent = "";
        //    titleContent =content;
        //    titlePopupBody.innerHTML = titleContent;
             
        //    titlePopup.show(0, popY, document.body.clientWidth, popupHeight, document.body); 
        //}
        //else
        {
            var popUp = document.getElementById("popupcontent");
            popUp.style.position = "absolute";
            popUp.style.display = "block";
            popUp.style.zIndex = 999;
            popUp.style.left=0+"px";
            popUp.style.top=popY+"px";
            popUp.style.width=document.body.clientWidth;
            //popUp.style.height=popupHeight;
            popUp.style.backgroundColor = "#f9f8f7"; 
            popUp.style.border = "solid #999999 1px"; 
            popUp.style.fontSize = "12px";
            popUp.innerHTML = content;
            popUp.style.visibility = "visible"; 
        }
       }
   
    function popupclose()
    {
        var popUp = document.getElementById("popupcontent");
        //popUp.style.height=0;
        popUp.innerHTML ="";
        //popUp.style.visibility = "hidden";
        popUp.style.display = "none";
    }
    */

    var xmlHttpRequest = null;
    function getXMLHttpRequest()
    {
	    if(window.XMLHttpRequest)
	    {
		    return new XMLHttpRequest();
	    }
	    else if (window.ActiveXObject)
	    {
		    request = new ActiveXObject("Microsoft.XMLHTTP");

		    if (!request)
		    {
			    request = new ActiveXObject("Msxml2.XMLHTTP");
			    if (!request)
			    {
				    request = null;
			    }
		    }

		    return request;
	    }
    }

    function query_trips() {
        var count;
        count = document.getElementById("MainContent_hidSegCount").value;
        for (i = 1; i <= count; i++) {
            query_fares(i,0);
        }
    }

    function query_fares(i, offset) {
        //confirm(i + "/" + offset);
        document.getElementById("seg_" + i).innerhtml = "";
        xmlHttpRequest = getXMLHttpRequest();
        if (xmlHttpRequest != null) {
            xmlHttpRequest.onreadystatechange = function () { ret_of_query_fares(i) };
            xmlHttpRequest.open("GET", "avail_open_fares.ashx?seg_sn=" + i+"&offset="+offset+"&ran="+Math.random(), false); //true=异步,false=同步
            xmlHttpRequest.send(null);
            //confirm(i);
        }
    }

    function ret_of_query_fares(i) {
        window.status = xmlHttpRequest.readyState;
        if (xmlHttpRequest.readyState == 4) {
            // everything is good, the response is received
            var obj = document.getElementById("seg_" + i);
            if (obj == null) {
                //confirm("Object not found!");
                return;
            }
            if (xmlHttpRequest.status == 200) {
                obj.innerHTML = xmlHttpRequest.responseText;
                //confirm("OK");
                //window.status=xmlHttpRequest.responseText;
                //InitMsgBox(xmlHttpRequest.responseText);
                //window.status=xmlHttpRequest.status;
                // perfect!
            } else {
                obj.innerHTML = "xmlHttpRequest failed!";
                // there was a problem with the request,
                // for example the response may be a 404 (Not Found)
                // or 500 (Internal Server Error) response codes
            }
        } else {
            // still not ready
            window.status = xmlHttpRequest.readyState;
        }
    }

/*
    function AjaxGetFareDetails(evt, url) {
        //get mouse position:
        if (document.all) {//in IE 
            popY = window.event.y + document.body.scrollTop+80;
        } 
        else {
            popY = evt.pageY+10;
        }

	    xmlHttpRequest = getXMLHttpRequest();
	    if(xmlHttpRequest!=null)
	    {
	        xmlHttpRequest.onreadystatechange = onFareDetailsReturn;
		    xmlHttpRequest.open("GET", url, false); //true=异步,false=同步
		    xmlHttpRequest.send(null);
	    }
    }

    function onFareDetailsReturn() {
	    window.status=xmlHttpRequest.readyState;
	    if (xmlHttpRequest.readyState == 4) {
	        // everything is good, the response is received
	        //alert(xmlHttpRequest.responseText);
		    if (xmlHttpRequest.status == 200) {
		        //window.status=xmlHttpRequest.responseText;
			    InitMsgBox(xmlHttpRequest.responseText);
			    //window.status=xmlHttpRequest.status;
			    // perfect!
		    } else {
			    InitMsgBox(xmlHttpRequest.responseText);
			    // there was a problem with the request,
			    // for example the response may be a 404 (Not Found)
			    // or 500 (Internal Server Error) response codes
		    }


	    } else {
	    // still not ready
		    window.status=xmlHttpRequest.readyState;
	    }

    }
*/
    // -->
    </script>

    <form id="form1" runat="server" role="form" class="form-inline">
    <%--<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate>--%>
    <div class="container-fluid body-content" style="width:100%;">

    <div class="row">
        <div class="col-sm-2 well well-sm">
            <h5><asp:Literal ID="litTitle" runat="server" meta:resourcekey="tipPageTitle"></asp:Literal></h5>
        </div>

        <div class="col-sm-10 well well-sm">
            <div class="panel">
                <div class="panel-heading btn-primary">
                    <h6 class="panel-title" id="section-2"><asp:Literal ID="Literal1" runat="server" meta:resourcekey="tipPageTitle"></asp:Literal></h6>
                </div>
                <div class="panel-body">
                    <div id="popupcontent" onclick = "popupclose();"></div>
                    <div class="table-responsive">
                        <asp:Literal ID="litSegments" runat="server"></asp:Literal>
                    </div>
                    <asp:Label ID="Label2" runat="server" Text="Note:Fare shows here is just refrence fare!" meta:resourcekey="Note"></asp:Label><br/>
                    <br />
                    <asp:Button ID="butNext" runat="server" Text="Next" CssClass="btn btn-sm btn-default" PostBackUrl="OrderContact.aspx" meta:resourcekey="Next" /><br />
                    <asp:Label ID="lblError" runat="server" CssClass="ifdMessage"></asp:Label>

                    <asp:HiddenField ID="hidSegCount" runat="server" />
                </div>
            </div>

            
        </div>
    </div>

    </div>
    <%--</ContentTemplate></asp:UpdatePanel>--%>
    </form>

    <!--不能放在UpdatePanel中！-->
    <div class="modal fade bs-example-modal-lg" id="modXXX" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" > <!--style="text-align:center;"-->
        <div class="modal-dialog modal-lg" style="width: 95%;"><!-- style="width: 100%;"-->
            <div class="modal-content">
                <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h6></h6>
                </div>
                <div class="modal-body">
                <p id="ajax1" class="ifdModal">Retrieving...</p>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <script>
        $(document).ready(function () {
            query_trips();
        });
  	</script>
</asp:Content>
